<template>
  <div id="app">
    <!-- <img alt="Vue logo" src="./assets/logo.png"> -->
    <!-- <HelloWorld msg="Welcome to Your Vue.js App"/> -->
    app组件的<input type="text" v-focusbind="num" />
    <p>全局过滤器{{ num | jianyi }}</p>
    <!-- <Son
      msg='carlos'
      :get_son_msg='get_son_msg'
    /> -->
    <Son ref="sonRef" />
    <Daughter/>
  </div>
</template>

<script>
import HelloWorld from "./components/HelloWorld.vue";
import Son from "./components/Son.vue";
import Daughter from './components/Daughter'

export default {
  name: "App",
  data() {
    return {
      num: 7,
    };
  },
  components: {
    HelloWorld,
    Son,
    Daughter
  },
  methods: {
    get_son_msg(msg) {
      console.log("app组件=>", msg);
    },
    //  ES6写法 params是形参
    fa_ask_msg(msg, ...params) {
      // params是一个数组
      console.log("fa_ask_msg被调用了", msg, params);
    },
  },
  mounted() {
    //第一个参数自定义事件
    // this.$refs.sonRef.$on("get_son_msg2", this.fa_ask_msg);
    //仅仅起作用一次。这里第一个参数和第二个参数都是父组件里面的。
    setTimeout(() => {
      // console.log(this.$refs.sonRef.$on);
      // console.log('app49');
      this.$refs.sonRef.$on("get_son_msg2", this.fa_ask_msg);
    }, 1000);
  },
};
</script>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>
